package com.xhui.reggie.utils;
import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest;
import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.profile.DefaultProfile;


/**
 * aliyun短信发送 工具类
 */
public class SMSUtils {

	/**
	 * 发送短信
	 * @param signName 签名
	 * @param templateCode 模板
	 * @param phoneNumbers 手机号
	 * @param param 参数
	 */
	public static void sendMessage(String signName, String templateCode,String phoneNumbers,String param){
		String accessKeyId = "";
		String secret = "";
		DefaultProfile profile = DefaultProfile.getProfile("cn-hangzhou", accessKeyId, secret);
		DefaultAcsClient client = new DefaultAcsClient(profile);

		SendSmsRequest request = new SendSmsRequest();
		request.setSysRegionId("cn-hangzhou");
		request.setSignName("阿里云短信测试");
		request.setTemplateCode("SMS_154950909");
		request.setPhoneNumbers("17339345399");
		request.setTemplateParam("{\"code\":\"1234\"}");

		try {
			SendSmsResponse response = client.getAcsResponse(request);
			System.out.println("短信发送成功");
		} catch (ClientException e) {
			throw new RuntimeException(e);
		}
	}


}
